//
//  AddStyleTipView.m
//  linkingGame
//
//  Created by zw wu on 15/4/19.
//  Copyright (c) 2015年 com.jinWu. All rights reserved.
//

#import "AddStyleTipView.h"

@interface AddStyleTipView ()

@property (nonatomic,retain) UILabel *titleLabel;

@end

@implementation AddStyleTipView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backBtn setTitle:NSLocalizedString(@"back",nil) forState:UIControlStateNormal];
        [self addSubview:backBtn];
        self.backBtn = backBtn;
        
        backBtn.backgroundColor = [UIColor grayColor];
        
        UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [addBtn setTitle:NSLocalizedString(@"Add",nil) forState:UIControlStateNormal];
        [self addSubview:addBtn];
        self.addBtn = addBtn;
        
        addBtn.backgroundColor = [UIColor grayColor];
        
        UILabel *titleLabel = [[UILabel alloc]init];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = [UIColor blackColor];
        titleLabel.text = NSLocalizedString(@"choose_style",nil);
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        titleLabel.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

- (void)dealloc
{
    self.backBtn = nil;
    self.addBtn = nil;
    self.titleLabel = nil;
    
    [super dealloc];
}

- (void)refreshUI
{
    CGRect backBtnRect,addBtnBtnRect,titleLabelRect;
    if (isPhone())
    {
        self.titleLabel.font = [UIFont boldSystemFontOfSize:24];
        
        backBtnRect = CGRectMake(22, 22, 44, 44);
        addBtnBtnRect = CGRectMake(self.frame.size.width - 66, 22, 44, 44);
        titleLabelRect = CGRectMake(66, 30, self.frame.size.width - 132, 30);
    }
    else
    {
        self.titleLabel.font = [UIFont boldSystemFontOfSize:30];
        
        if (isLandscape())
        {
            backBtnRect = CGRectMake(30, 30, 60, 60);
            addBtnBtnRect = CGRectMake(self.frame.size.width - 90, 30, 60, 60);
            titleLabelRect = CGRectMake(90, 30, self.frame.size.width - 180, 60);
        }
        else
        {
            backBtnRect = CGRectMake(45, 45, 90, 90);
            addBtnBtnRect = CGRectMake(self.frame.size.width - 135, 45, 90, 90);
            titleLabelRect = CGRectMake(135, 60, self.frame.size.width - 270, 60);
        }
    }
    
    self.backBtn.frame = backBtnRect;
    self.addBtn.frame = addBtnBtnRect;
    self.titleLabel.frame = titleLabelRect;
}

@end
